package fun.yaozun.study.service.impl;

import fun.yaozun.study.mapper.study.UserMapper;
import fun.yaozun.study.model.RestModel;
import fun.yaozun.study.model.User;
import fun.yaozun.study.service.ITestService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Auther: yaozun
 * @Date: 2018/5/9 0009 09:42
 * @Description:
 */
@Service
public class TestServiceImpl implements ITestService{
    private static Logger log = LoggerFactory.getLogger(TestServiceImpl.class);

    @Autowired
    private UserMapper userMapper;


    @Override
    public RestModel addUser(User user) {
        try{
            int is_success = userMapper.insert(user);
            if (is_success==1){return new RestModel("新增用户成功");}
            if (is_success==0){return new RestModel("新增用户失败");}
        }catch (Exception e){
            log.error(e.getMessage());
            return new RestModel("205",e.getMessage().toString());
        }
        return new RestModel();
    }
}
